<?php
/**
* openDocument library kit
*
* @link http://webappkit.net
* @package pathnodes
* @subpackage od
* @author J.Ducastel <jeremie@ducastel.name>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

/**
* provides access to opendocument elements when zipped as an archive
* @uses odContentNode
* @todo fragment content updating
*/
class odContainer_zip extends zipArchiveNode {
/*--------------------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------------------*/
	/**
	* constructor alias
	* @access public
	* /
	function () {
		$this->__construct();
	}/**/
	
	/**
	* "real" constructor
	* @access public
	* /
	function __construct() {
		
	}/**/
/*--------------------------------------------------------------------
PUBLIC STATIC METHODS
--------------------------------------------------------------------*/
	/**
	* @return bool
	*/
	function selfDetector($path) {
		return file_exists($path) and is_file($path);
	}/**/

	/**
	* clone form another container
	* @static
	* @param odContainer_folder $container
	* @return odContainer_zip
	* /
	function & cloneFrom($container) {
		// cloning self
		$clone=$this;
		return $clone;
	}/**/
/*--------------------------------------------------------------------
PUBLIC INSTANCE METHODS
--------------------------------------------------------------------*/
	/**
	* get content reference
	* @access public
	* @return odContentNode
	*/
	function & getContent() {
		// trying to build content if not done
		if (!$this->content
		// getting virtual file from zip archive
		and $zipchild=$this->getChild('content.xml')) {
			// echo '<pre>'; print_r($zipchild);
			// extracting file's content
			$str=$zipchild->extract(); // echo $str;
			// building xml node
			$this->content=&new odContentNode($str);
			$this->content->setContainer($this);
		}
		return $this->content;
	}/**/
	
	/**
	 * receives child nodes update notification
	 * @access public
	 * @param odXmlFragment $child
	 * @return bool
	 */
	function childUpdated(&$child) {
		switch ($child->getid()) {
			case $this->content->getid():
				// getting content xml
				$xml=$this->content->getDocumentXml(); // echo $xml;
				// getting virtual file
				$file=&$this->getChild('content.xml');
				// setting content
				$file->content($xml);
				// echo '<pre>'; print_r($file); exit;
				// echo "<p>content updated !</p>";
				break;
		}
	}

/*--------------------------------------------------------------------
VARS / MEMBERS
--------------------------------------------------------------------*/
	/**
	* @var odContentNode
	*/
	var $content;
	
/*--------------------------------------------------------------------
PRIVATE / PROTECTED METHODS
--------------------------------------------------------------------*/
	/**
	* 
	* @param
	* @access protected
	* @return 
	* /
	function () {
		
	}/**/
}
?>